{
 "metadata": {
  "name": "",
  "signature": "sha256:ffb74821d7a49737523785b6fd33237707934dda1dead2531b7610d892d1c5e9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import os\n",
      "import pandas as pd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def data_label(path):\n",
      "    label = pd.read_csv('label.csv', header = None)\n",
      "    files_list = os.listdir(path)\n",
      "    pic_list = []\n",
      "    label_list = []\n",
      "    for file_ in files_list:\n",
      "        prefix, type_ = os.path.splitext(file_)\n",
      "        if type_ == \".jpg\":\n",
      "            pic_list.append(file_)\n",
      "            index = int(prefix)\n",
      "            label_list.append(label.iat[index, 0])\n",
      "    pic_s = pd.Series(pic_list)\n",
      "    label_s = pd.Series(label_list)\n",
      "    df = pd.DataFrame()\n",
      "    df['pic'] = pic_s\n",
      "    df['label'] = label_s\n",
      "    path = os.path.join(path, \"dataset.csv\")\n",
      "    df.to_csv(path, index=False, header=False)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 17
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "train_pic = r\"/media/root/515e7d3a-49ac-40be-ba58-fef9702d123c/work_record/\u4f5c\u4e1a3/face/train\"\n",
      "val_pic = r\"/media/root/515e7d3a-49ac-40be-ba58-fef9702d123c/work_record/\u4f5c\u4e1a3/face/val\"\n",
      "data_label(train_pic)\n",
      "data_label(val_pic)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 19
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "label = pd.read_csv('label.csv', header = None)\n",
      "label.iat[4,0]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 13,
       "text": [
        "6"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}